package topday1_9.chj;

import java.util.Scanner;

/**
 * @Auther:小陈的Java
 */
class Fibonacci {
    public static int fib(int n) {
        if (n==0)
            return 0;
        else if(n==1 || n==2)
            return 1;
        else
            return fib(n-1)+fib(n-2);
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("输出第几项斐波那契数：");
        int n=input.nextInt();
        System.out.println("第"+n+"项数为："+fib(n));
        for(int i=0;i<=n;i++) {
            System.out.print(fib(i)+" ");
        }
    }
}
